﻿using EmitMapper;

namespace Als.Utils.Data
{
    /// <summary>
    /// 映射扩展
    /// </summary>
    public static class Mapping
    {
        /// <summary>
        /// DTO映射
        /// </summary>
        /// <typeparam name="TFrom"></typeparam>
        /// <typeparam name="TTo"></typeparam>
        /// <param name="tFrom"></param>
        /// <param name="iMappingConfigurator"></param>
        /// <returns></returns>
        public static TTo ToDto<TFrom, TTo>(this TFrom tFrom, IMappingConfigurator iMappingConfigurator = null)
        {
            var mapper = iMappingConfigurator == null ? ObjectMapperManager.DefaultInstance.GetMapper<TFrom, TTo>() : ObjectMapperManager.DefaultInstance.GetMapper<TFrom, TTo>(iMappingConfigurator);
            return mapper.Map(tFrom);
        }





    }
}
